package com.huike.business.service.impl;


import com.huike.business.domain.TbBusiness;
import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.mapper.TbBusinessMapper;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.clues.service.ISysDictDataService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {

    @Autowired
    private TbBusinessTrackRecordMapper recordMapper;
    @Autowired
    private TbBusinessMapper businessMapper;
    @Autowired
    private ISysDictDataService sysDictDataService;


    @Override
    public void add(BusinessTrackVo businessTrackRecord) {
        businessTrackRecord.setCreateBy(SecurityUtils.getUsername());
        businessTrackRecord.setCreateTime(DateUtils.getNowDate());
        recordMapper.add(businessTrackRecord);
        //修改商机
        TbBusiness business = new TbBusiness();
        business.setId(businessTrackRecord.getBusinessId());
        business.setName(businessTrackRecord.getName());
        business.setPhone(businessTrackRecord.getPhone());
        business.setOccupation(businessTrackRecord.getOccupation());
        business.setEducation(businessTrackRecord.getEducation());
        business.setProvinces(businessTrackRecord.getProvinces());
        business.setCity(businessTrackRecord.getCity());
        business.setWeixin(businessTrackRecord.getWeixin());
        business.setAge(businessTrackRecord.getAge());
        business.setMajor(businessTrackRecord.getMajor());
        business.setJob(businessTrackRecord.getJob());
        business.setSalary(businessTrackRecord.getSalary());
        business.setQq(businessTrackRecord.getQq());
        business.setSex(businessTrackRecord.getSex());
        business.setExpectedSalary(businessTrackRecord.getExpectedSalary());
        business.setRemark(businessTrackRecord.getRemark());
        business.setSubject(businessTrackRecord.getSubject());
        business.setReasons(businessTrackRecord.getReasons());
        business.setPlan(businessTrackRecord.getPlan());
        businessMapper.updateTbBusiness(business);
    }

    @Override
    public List<BusinessTrackVo> list(Long businessId) {

        return recordMapper.list(businessId);
    }
}
